package cn.antblog.code.test1;


import java.util.ArrayList;
import java.util.List;

public class ProductService {

    public static void main(String[] args) {
        //数据库中存储多个枚举的时候，使用 | 运算符，将结果值存储到数据库字段。
        int lable1 = LableEnum.YIFU.getCode() | LableEnum.KUZI.getCode() | LableEnum.MAOZI.getCode();
        int lable2 = LableEnum.YIFU.getCode() | LableEnum.KUZI.getCode();
        int lable3 = LableEnum.KUZI.getCode() | LableEnum.XIEZI.getCode();

        //数据库中存储多个枚举的时候，使用 & 运算符，将结果值存储到数据库字段。 不成立
//        int lable1 = LableEnum.YIFU.getCode() & LableEnum.KUZI.getCode() & LableEnum.MAOZI.getCode();
//        int lable2 = LableEnum.YIFU.getCode() & LableEnum.KUZI.getCode();
//        int lable3 = LableEnum.KUZI.getCode() & LableEnum.XIEZI.getCode();

        System.out.println(lable1);
        System.out.println(lable3);
        System.out.println(lable2);



    }

//    public static List<String> getLableNames(int code) {
//        LableEnum[] lableEnums = LableEnum.values();
//        List<String> result = new ArrayList<>();
//        for (LableEnum lableEnum : lableEnums) {
//            if ((lableEnum.getCode() | code) != 0) {
//                result.add(lableEnum.getLableName());
//            }
//        }
//        return result;
//    }
}
